package com.yonyou.brigade.order_center.controller;

import com.alibaba.fastjson.JSONObject;
import com.yonyou.brigade.order_center.service.IReportDataService;
import com.yonyou.brigade.order_center.service.IReportModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author houyb
 */

@Controller
@RequestMapping("/report/api/v1")
public class BriOrderReportController{

    @Autowired
    private IReportModelService reportModelService;

    @Autowired
    private IReportDataService reportDataService;

    @RequestMapping(value = "/model", method = RequestMethod.GET)
    @ResponseBody
    public Object model(HttpServletRequest req){
        return reportModelService.queryModel();
    }

    @RequestMapping(value = "/query", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject query(@RequestBody JSONObject data, HttpServletRequest request) throws Exception {

        return reportDataService.getModelData(data, request);
    }
}
